enum Side;

ref class Trigger
{
public:
	property Account ^AccountP { Account ^get(){ return account; } }
	property Bars ^BarsP { Bars ^get(){ return bars; } }
	property String ^SymbolName { String ^get(){ return symbolName; } }
	property Limit ^LimitP { Limit ^get(){ return limit; } }
	property Side Trend { Side get(){ return side; } }
	property float TriggerPrice { float get(){ return triggerPrice; } }
	property float TriggerLimitPrice { float get(){ return triggerLimitPrice; } }
	property float TriggerStopPrice { float get(){ return triggerStopPrice; } }
	property int Quantity { int get(){ return quantity; } }
	property int QuantityFilled { int get(){ return quantityFilled; } }
	property float StopLossPrice { float get(){ return stopLossPrice; } void set(float val){ stopLossPrice = val; } }
	property float OriginalStopLossPrice { float get(){ return originalStopLossPrice; } void set(float val){ originalStopLossPrice = val; } }
	property float RiskByCents { float get(){ return riskByCents; } }
	property float OnlineLast { float get(){ return onlineLast; } }
	property bool InActive { bool get(){ return inActive; } }
	property int Limit_1_OrderID { int get(){ return limit_1_OrderID; } }
	property int Limit_2_OrderID { int get(){ return limit_2_OrderID; } }
	property int Limit_3_OrderID { int get(){ return limit_3_OrderID; } }
	property int Limit_4_OrderID { int get(){ return limit_4_OrderID; } }
	property int TideStop { int get(){ return tideStop; } }
	property int TideStopSpace { int get(){ return tideStopSpace; } }
	property int TideStopStartAfter { int get(){ return tideStopStartAfter; } void set(int val){ tideStopStartAfter = val; } }
	property int StopLossSpread { int get(){ return stopLossSpread; } }
	property int RoundANumber { int get(){ return roundANumber; } }
	property int RoundStopNumber { int get(){ return roundStopNumber; } }

	Trigger(String ^symName, float triggerPrice, float stopLossCents, int qSize, Side sd, Account ^acc, Bars ^br); // Constructor
	void CloseTrigger(bool StopInMKT);

	int triggerOrderID;
	bool triggerIsActive;
	int stopOrderID;
	bool stopIsActive;
	bool stopMktPerformed;
	int limit_1_OrderID;
	int limit_2_OrderID;
	int limit_3_OrderID;
	int limit_4_OrderID;
	float stopLossPrice; // The stop loss price
	float originalStopLossPrice; // The original stop loss price

protected:
	Account ^account;
	Limit ^limit;
	Bars ^bars;

	String^ symbolName;
	String^ triggerTime; // The time that the trigger performed
	float triggerPrice; // The trigger itself
	float stopLossCents; // Stop loss in cents
	Side side; // Trend (Long\Short)
	float triggerStopPrice;
	float triggerLimitPrice;
	float triggerSpread; // The distance between stop price and limit price
	float riskByCents; // The distance between the trigger to the stop loss
	int quantity;
	int quantityFilled;
	float onlineLast;
	int onlineLastID;
	int tideStop;
	int tideStopSpace;
	int tideStopStartAfter;
	int stopLossSpread;
	int roundANumber;
	int roundStopNumber;

	Timer tmr;
	bool inActive;

	void TriggerFilled(System::Object^  sender, AxTWSLib::_DTwsEvents_orderStatusEvent^  e);
	void UpdatePrice(System::Object^  sender, AxTWSLib::_DTwsEvents_tickPriceEvent^  e);
	void PerformLimits(System::Object^ sender, System::EventArgs^ e);
};
